/*
 * Contract.java
 * 
 * Copyright 2011 Matt Whipple <matt@mattwhipple.com>
 * 
 * This file is part of com.teamsuperfitness.apps
 * 
 * com.teamsuperfitness.apps is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 * 
 * com.teamsuperfitness.apps is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with com.teamsuperfitness.apps. If not, see http://www.gnu.org/licenses/.
 */

package com.teamsuperfitness.apps.shared.model;

import java.io.Serializable;
import java.util.Date;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

import org.slim3.datastore.Attribute;
import org.slim3.datastore.Model;

@Model(schemaVersion = 1)
public class Contract implements Serializable {

    private static final long serialVersionUID = 1L;

    @Attribute(primaryKey = true)
    private Key key;
    private Long id;
    
    @Attribute(version = true)
    private Long version;

    private Date date;
    private String remarks;
    private String contractNumber;
    private String name;
    private String phone;
    private Double gross;
    private Long monthsFinanced;
    private String salesPerson;
    private Double percent;
    private Long monthsInMembership;
    private String methodOfPayment;
    private Double cash;
    private Double net;
    private Double commission;
    private String source;
    private String club;
    
    private Boolean hold;
    private Boolean voidContract;
    private Boolean comp;
    /**
     * Returns the key.
     *
     * @return the key
     */
    public Key getKey() {
        return key;
    }

    /**
     * Sets the key.
     *
     * @param key
     *            the key
     */
    public void setKey(Key key) {
        this.key = key;
        this.id = key.getId();
    }

    public Long getId() {
        return this.id;
    }
    public void setId(Long id) {
        this.id = id;
        this.key = KeyFactory.createKey(getKind(), id);
    }
    
    public String getKind() {
        return "Contract";
    }
    
    /**
     * Returns the version.
     *
     * @return the version
     */
    public Long getVersion() {
        return version;
    }

    /**
     * Sets the version.
     *
     * @param version
     *            the version
     */
    public void setVersion(Long version) {
        this.version = version;
    }

    /**
     * @return the created
     */
    public Date getDate() {
        return date;
    }

    /**
     * @param created the created to set
     */
    public void setDate(Date date) {
        this.date = date;
    }

    /**
     * @return the remarks
     */
    public String getRemarks() {
        return remarks;
    }

    /**
     * @param remarks the remarks to set
     */
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    /**
     * @return the contractNumber
     */
    public String getContractNumber() {
        return contractNumber;
    }

    /**
     * @param contractNumber the contractNumber to set
     */
    public void setContractNumber(String contractNumber) {
        this.contractNumber = contractNumber;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the phone
     */
    public String getPhone() {
        return phone;
    }

    /**
     * @param phone the phone to set
     */
    public void setPhone(String phone) {
        this.phone = phone;
    }

    /**
     * @return the gross
     */
    public Double getGross() {
        return gross;
    }

    /**
     * @param gross the gross to set
     */
    public void setGross(Double gross) {
        this.gross = gross;
    }

    /**
     * @return the monthsFinanced
     */
    public Long getMonthsFinanced() {
        return monthsFinanced;
    }

    /**
     * @param monthsFinanced the monthsFinanced to set
     */
    public void setMonthsFinanced(Long monthsFinanced) {
        this.monthsFinanced = monthsFinanced;
    }

    /**
     * @return the salesPerson
     */
    public String getSalesPerson() {
        return salesPerson;
    }

    /**
     * @param salesPerson the salesPerson to set
     */
    public void setSalesPerson(String salesPerson) {
        this.salesPerson = salesPerson;
    }

    /**
     * @return the percent
     */
    public Double getPercent() {
        return percent;
    }

    /**
     * @param percent the percent to set
     */
    public void setPercent(Double percent) {
        this.percent = percent;
    }

    /**
     * @return the monthsInMembership
     */
    public Long getMonthsInMembership() {
        return monthsInMembership;
    }

    /**
     * @param monthsInMembership the monthsInMembership to set
     */
    public void setMonthsInMembership(Long monthsInMembership) {
        this.monthsInMembership = monthsInMembership;
    }

    /**
     * @return the methodOfPayment
     */
    public String getMethodOfPayment() {
        return methodOfPayment;
    }

    /**
     * @param methodOfPayment the methodOfPayment to set
     */
    public void setMethodOfPayment(String methodOfPayment) {
        this.methodOfPayment = methodOfPayment;
    }

    /**
     * @return the cash
     */
    public Double getCash() {
        return cash;
    }

    /**
     * @param cash the cash to set
     */
    public void setCash(Double cash) {
        this.cash = cash;
    }

    /**
     * @return the net
     */
    public Double getNet() {
        return net;
    }

    /**
     * @param net the net to set
     */
    public void setNet(Double net) {
        this.net = net;
    }

    /**
     * @return the commission
     */
    public Double getCommission() {
        return commission;
    }

    /**
     * @param commission the commission to set
     */
    public void setCommission(Double commission) {
        this.commission = commission;
    }

    /**
     * @return the source
     */
    public String getSource() {
        return source;
    }

    /**
     * @param source the source to set
     */
    public void setSource(String source) {
        this.source = source;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((key == null) ? 0 : key.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Contract other = (Contract) obj;
        if (key == null) {
            if (other.key != null) {
                return false;
            }
        } else if (!key.equals(other.key)) {
            return false;
        }
        return true;
    }

    /**
     * @return the hold
     */
    public Boolean getHold() {
        return hold;
    }

    /**
     * @param hold the hold to set
     */
    public void setHold(Boolean hold) {
        this.hold = hold;
    }

    /**
     * @return the voidContract
     */
    public Boolean getVoidContract() {
        return voidContract;
    }

    /**
     * @param voidContract the voidContract to set
     */
    public void setVoidContract(Boolean voidContract) {
        this.voidContract = voidContract;
    }

    /**
     * @return the comp
     */
    public Boolean getComp() {
        return comp;
    }

    /**
     * @param comp the comp to set
     */
    public void setComp(Boolean comp) {
        this.comp = comp;
    }

    /**
     * @return the club
     */
    public String getClub() {
        return club;
    }

    /**
     * @param club the club to set
     */
    public void setClub(String club) {
        this.club = club;
    }
}
